"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));

var _utils = require("../utils");

var _functional = require("../utils/functional");

var _cell = _interopRequireDefault(require("../cell"));

var _createNamespace = (0, _utils.createNamespace)('contact-card'),
    createComponent = _createNamespace[0],
    bem = _createNamespace[1],
    t = _createNamespace[2];

function ContactCard(h, props, slots, ctx) {
    var type = props.type,
        editable = props.editable;

    function onClick(event) {
        if (editable) {
            (0, _functional.emit)(ctx, 'click', event);
        }
    }

    function Content() {
        if (type === 'add') {
            return props.addText || t('addText');
        }

        return [h("div", [t('name') + "\uFF1A" + props.name]), h("div", [t('tel') + "\uFF1A" + props.tel])];
    }

    return h(_cell.default, (0, _babelHelperVueJsxMergeProps.default)([{
        "attrs": {
            "center": true,
            "border": false,
            "isLink": editable,
            "valueClass": bem('value'),
            "icon": type === 'edit' ? 'contact' : 'add-square'
        },
        "class": bem([type]),
        "on": {
            "click": onClick
        }
    }, (0, _functional.inherit)(ctx)]), [Content()]);
}

ContactCard.props = {
    tel: String,
    name: String,
    addText: String,
    editable: {
        type: Boolean,
        default: true
    },
    type: {
        type: String,
        default: 'add'
    }
};

var _default = createComponent(ContactCard);

exports.default = _default;